

/** 游戏主页-demo1 */

import PageManager_blxf from "./Manager/PageManager";
import { ConfigModule_blxf } from "./Module/ConfigModule";
import { UtilsModule_blxf } from "./Module/UtilsModule";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Game_blxf extends cc.Component {

    @property({ type: cc.Node, tooltip: '背景节点' })
    bgNode: cc.Node = null;

    @property({ type: [cc.Node], tooltip: '适配节点列表' })
    nodeList: cc.Node[] = [];

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        // UtilsModule_blxf.instance.setNodeSize_blxf( this.bgNode );

        // this.initSize_blxf();
    }

    start () {

    }

    update (dt) {

    }

    /** 初始化页面尺寸 */
    initSize_blxf () {
        UtilsModule_blxf.instance.setNodeSize_blxf( this.node );

        let { checkH, isIpad, winSizeW } = ConfigModule_blxf.instance;
        this.nodeList.forEach( (item, index) =>{
            if ( index == 1 ) item.height += checkH / 2;
            let _updateH: number;
            switch ( index ) {
                case 0 : _updateH = -checkH * 3 / 4; break;
                case 1 : _updateH = -checkH; break;
                case 2 : _updateH = checkH; break;
            }
            item.y += _updateH;
        })

        if ( isIpad ) this.bgNode.width = winSizeW;
    }
}
